<?php
	if(isset($_POST["HotelesDisponibles"]) ){
		$idHotel=$_POST["HotelesDisponibles"];
		$db=new DB();
		$query="Select Nombre from hoteles where Id_Hotel='{$idHotel}'";
		$result=$db->query($query);
		$row=$db->getRow();
		$NameHotel=$row[0];
		$db->close();
?>
<style type="text/css">@import url(../css/calendar.css);</style>
<script language="javascript" src="../js/operadoraLib.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="../js/calendar.js" ></script>
<script type="text/javascript" src="../js/calendar-es.js" language="javascript"></script>
<script type="text/javascript" src="../js/calendar-setup.js" language="javascript"></script>
<form name="promocionForm" action="Promociones.php" method="post">
<input type="hidden" id="idHotel" name="idHotel" value="<?php echo $idHotel; ?>" />
<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
    <tr>
      <td class="formtitle" align="left" colspan="2">
      Codificaciones para Aplicar Promoci&oacute;n</td>
    </tr>
    <tr>
    	<td class="formtitle" align="left" colspan="2">
        	Hotel que aplica la promoci&oacute;n:&nbsp;
            <?php
				echo $NameHotel;
			?>
        </td>
    </tr>
    <tr>
      <td class="formLabel" align="left" colspan="2"><hr />Fecha que Aplica la Promoci&oacute;n<br />
          <br />Fecha Inicia :       
            <input type="text" id="Date" name="Date" readonly="readonly" style="font-size:9px; vertical-align:middle;" />
            <img style="vertical-align:middle;" class="btnCalendar" src="../images/calendar.jpg" id="trigger" onMouseOver="this.style.border='1px outset #000000';" onMouseOut="this.style.border='1px outset #CCCCCC';" />
            <script type="text/javascript">
				Calendar.setup(
					{
						inputField : "Date", // ID of the input field
						ifFormat : "%Y-%m-%d", // the date format
						button : "trigger" // ID of the button
					}
				);
			</script>
       <br />Fecha Final :
            <input type="text" id="eventDateEnd" readonly="readonly" name="eventDateEnd" style="font-size:9px; vertical-align:middle;" />
            <img style="vertical-align:middle;" class="btnCalendar" src="../images/calendar.jpg" id="trigger2" onMouseOver="this.style.border='1px outset #000000';" onMouseOut="this.style.border='1px outset #CCCCCC';" />
            <script type="text/javascript">
				Calendar.setup(
					{
						inputField : "eventDateEnd", // ID of the input field
						ifFormat : "%Y-%m-%d", // the date format
						button : "trigger2" // ID of the button
					}
				);
			</script>
    </td>
  </tr>
  <tr>
    <td colspan="2" class="formtitle"><hr />Generar Condici&oacute;n<br />
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr class="formLabel" align="left">
            <td width="17%">&nbsp;Tipo Habitaci&oacute;n&nbsp;</td>
            <td width="17%">&nbsp;Ocupaci&oacute;n&nbsp;</td>
            <td width="17%">&nbsp;Plan&nbsp;</td>
          	<td width="24%">&nbsp;Numero Habitaciones</td>
            <td width="25%">&nbsp;Numero de Noches</td>
        </tr>
      <tr>
            <td>
            	<select name="tipoHabitacion" style="font-size:9px;">
                <?php 
                    $arr=getRoomType($idHotel);
                    foreach($arr as $a){
                        echo "<option value='{$a[0]}'>{$a[1]}</option>";
                    }
                ?>
                </select>
            </td>
            <td>
                <select name="ocupacion" style="font-size:9px;">
                <?php
                    $arr=getOcupation($idHotel);
                    foreach($arr as $a){
                        echo "<option value='{$a[0]}'>{$a[0]}</option>";
                    }
                ?>
                </select>
            </td>
            <td>
                <select name="plan" style="font-size:9px;">
                <?php
                    $arr=getPlan($idHotel);
                    foreach($arr as $a){
                        echo "<option value='{$a[0]}'>{$a[0]}</option>";
                    }
                ?>
                </select>
            </td>
          <td width="24%">
<select name="condicion" style="font-size:9px;" >
                    <option value="menor"><</option>
                    <option value="mayor">></option>
                    <option value="igual">=</option>
                    <option value="menIg"><=</option>
                    <option value="mayIg">>=</option>
            </select>
            <input type="text" value="0" name="numHabitaciones" size="3" style="font-size:9px;" />
        </td>
          <td>
              <select name="condicionNoches" style="font-size:9px;">
                <option value="menor"><</option>
                <option value="mayor">></option>
                <option value="igual">=</option>
                <option value="menIg"><=</option>
                <option value="mayIg">>=</option>
            </select><input type="text" value="0" name="numNoches" size="3" style="font-size:9px;" />
        </td>
      </tr>
      <tr class="formLabel" align="left">
        <td colspan="5">Cantidad Ocupantes</td>
      </tr>
      <tr>
        <td colspan="5">
            <table border="0" cellpadding="0" cellspacing="0">
            <tr class="formLabel" align="left" valign="top">
                <td style="background-image:none; background-color:#CCCCCC;">&nbsp;Menores&nbsp;</td>
                <td style="background-image:none; background-color:#CCCCCC;">&nbsp;Juniors&nbsp;</td>
                <td style="background-image:none; background-color:#CCCCCC;">&nbsp;Indiferente&nbsp;</td>
                <td>&nbsp;Adultos&nbsp;</td>
                <td>&nbsp;Mayores de X a&ntilde;os</td>
            </tr>
            <tr>
                <td style="background-image:none; background-color:#CCCCCC;"><select name="condicionMenores" style="font-size:9px;">
                    <option value="menor"><</option>
                    <option value="mayor">></option>
                    <option value="igual">=</option>
                    <option value="menIg"><=</option>
                    <option value="mayIg">>=</option>
                </select><input type="text" value="0" name="numMenores" size="2" style="font-size:9px;" />
                </td>
                <td style="background-image:none; background-color:#CCCCCC;"><select name="condicionJuniors" style="font-size:9px;">
                    <option value="menor"><</option>
                    <option value="mayor">></option>
                    <option value="igual">=</option>
                    <option value="menIg"><=</option>
                    <option value="mayIg">>=</option>
                </select><input type="text" value="0" name="numJuniors" size="2" style="font-size:9px;" />
                </td>
                <td style="background-image:none; background-color:#CCCCCC;"><select name="condicionIndif" style="font-size:9px;">
                    <option value="menor"><</option>
                    <option value="mayor">></option>
                    <option value="igual">=</option>
                    <option value="menIg"><=</option>
                    <option value="mayIg">>=</option>
                </select><input type="text" value="0" name="numIndif" size="2" style="font-size:9px;" />
                </td>
                <td><select name="condicionAdultos" style="font-size:9px;">
                    <option value="menor"><</option>
                    <option value="mayor">></option>
                    <option value="igual">=</option>
                    <option value="menIg"><=</option>
                    <option value="mayIg">>=</option>
                </select><input type="text" value="0" name="numAdultos" size="2" style="font-size:9px;" />
                </td>
                <td><select name="condicionMayores" style="font-size:9px;">
                    <option value="menor"><</option>
                    <option value="mayor">></option>
                    <option value="igual">=</option>
                    <option value="menIg"><=</option>
                    <option value="mayIg">>=</option>
                </select><input type="text" value="0" name="numMayores" size="2" style="font-size:9px;"/>
                </td>
            </tr>
            </table>
        </td>
      </tr>
      <tr>
        <td colspan="5">
        <textarea readonly name="conProm" rows="2" cols="82" style="font-size:10px;">Sentencia de la condici&oacute;n
        </textarea>
        <input type="button" value="Generar Condici&oacute;n" onclick="generaCondicion(document.promocionForm);" style="font-size:9px;" /></td>
      </tr>
    </table>
    </td>
  </tr>  
  <tr><td colspan="2"><hr /></td></tr>
  <tr>
    <td colspan="2" class="formtitle" align="left">Beneficio de la Promoci&oacute;n</td>
  </tr>
  <tr>
    <td colspan="2">
        <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr align="left">
            <td class="formLabel">Tipo Habitaci&oacute;n</td>
            <td class="formLabel">Ocupaci&oacute;n</td>
            <td class="formLabel">Descuento Habitaci&oacute;n</td>
            </tr><tr align="left">
            <td>
                <select name="tipoHabitacionBene" style="font-size:9px;">
                <?php 
                    $arr=getRoomType($idHotel);
                    foreach($arr as $a){
                        echo "<option value='{$a[0]}'>{$a[1]}</option>";
                    }
                ?>
                </select>
            </td>
            <td>
                <select name="ocupacionBene" style="font-size:9px;">
                <?php
                    $arr=getOcupation($idHotel);
                    foreach($arr as $a){
                        echo "<option value='{$a[0]}'>{$a[0]}</option>";
                    }
                ?>
                </select>
            </td>
            <td>
                <input type="text" name="descuentoHabita" style="font-size:9px;" value="0%" />
            </td>
            </tr>
            <tr align="left">
            <td class="formLabel">Plan</td>
            <td class="formLabel">Descuento Plan</td>
            <td class="formLabel">N&deg; Noches Cortesia</td>
            </tr><tr>
            <td>
                <select name="planBene" style="font-size:9px;">
                <?php
                    $arr=getPlan($idHotel);
                    foreach($arr as $a){
                        echo "<option value='{$a[0]}'>{$a[0]}</option>";
                    }
                ?>
                </select>
            </td>
            <td>
                <input type="text" name="descPlan" style="font-size:9px;" value="0%">
            </td>
            <td>
                <input type="text" name="nochesCorte" style="font-size:9px;" value="0" />
            </td>
            </tr>
        </table><tr><td colspan="2">
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
            <tr class="formTitle">
            <td colspan="5">Descuentos en Ocupantes</td>
            </tr>
            <tr class="formLabel">
                <td>Aplica en Menor</td>
                <td>Aplica en Junior</td>
                <td>Aplica en Indiferente</td>
                <td>Aplica en Adultos</td>
                <td>Aplica en Edad</td>
            </tr>
            <tr class="formLabel">
                <td><input type="text" size="3" style="font-size:9px;" value="0%" name="desMenor" />
                <input type="text" style="font-size:9px;" size="3" value="0" name="ndMenor"  />
                </td>
                <td><input type="text" size="3" style="font-size:9px;" value="0%" name="desJunior" />
                <input type="text" style="font-size:9px;" size="3" value="0" name="ndJunior"  />
                </td>
                <td><input type="text" size="3" style="font-size:9px;" value="0%" name="desIndi" />
                <input type="text" style="font-size:9px;" size="3" value="0" name="ndIndi"  />
                </td>
                <td><input type="text" size="3" style="font-size:9px;" value="0%" name="desAdulto" />
                <input type="text" style="font-size:9px;" size="3" value="0" name="ndAdulto"  />
                </td>
                <td><input type="text" size="3" style="font-size:9px;" value="0%" name="desEdad" />
                <input type="text" style="font-size:9px;" size="3" value="0" name="ndEdad"  />
                </td>
            </tr>
        </table></td></tr>
    </td>
  </tr>
  <tr>
    <td><hr /></td>
  </tr>
  <tr>
    <td class="formLabel" align="right">
    N&deg; Habitaciones que Aplica:&nbsp;
    <input type="text" size="3" value="0" name="nAplica" style="font-size:9px;" />
    </td>
  </tr>
  <tr align="center">
  	<td><div align="left" class="formLabel">&nbsp;&nbsp;&nbsp;&nbsp;Comentarios:</div>
    <textarea name="comentarios" rows="10" cols="75"></textarea></td>
  </tr>
  <tr>
    <td class="formLabel" align="right">
    <input type="button" onclick="finalizePromoForm(document.promocionForm)" value="Generar Promoci&oacute;n" style="font-size:9px;" />
    </td>
  </tr>
</table>
</form>
<?php
	}else{
?>
<form name="selectHotel" method="post" action="Promociones.php">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
    	<td>
        	Selecciona el Hotel al cual se le aplicara la promoci&oacute;n:
        </td>
    </tr>
    <tr>
		<td align="center">
			<select name='HotelesDisponibles'>
            <?php
				$db=new DB();
				$query="Select Id_Hotel,Nombre from hoteles order by Nombre ASC";
				$result=$db->query($query);
				if($db->total()>0){
					while($row=$db->getRow()){
						echo "<option value='{$row[0]}'>{$row[1]}</option>";
					}
				}
				$db->close();
			?>
            </select>
        </td>
    </tr>
    <tr>
    	<td align="center">
        	<input type="submit" value="Generar Condiciones" />
        </td>
    </tr>
</table>
</form>
<?php
	}
?>